Datashader Charts

line chart

datashader.line(y, data_points=100, add_interaction=True, pixel_shade_type='linear', color=None, step_size=None, step_size_type=<class 'int'>, width=800, height=400, title='', timeout=100, **library_specific_params)
Parameters
x: str

x-axis column name from the gpu dataframe

y: str

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[y].min(), gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
pixel_shade_type: str, default ‘linear’

The “how” parameter in datashader.transfer_functions.shade() function. Available options: eq_hist, linear, log, cbrt

color: str, default #8735fb
step_size: int, default None

for the range_slider below the chart

step_size_type: type, default int

for the range_slider below the chart

width: int, default 800
height: int, default 400
title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader scatter plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import DataFrame
from cuxfilter.charts.datashader import line
import numpy as np
import cudf
import random
import cuxfilter

n = 100000                           # Number of points
start = 1456297053                   # Start time
end = start + 60 * 60 * 24

cux_df = DataFrame.from_dataframe(cudf.DataFrame({'x': np.linspace(start, end, n), 'y':np.random.normal(0, 0.3, size=n).cumsum() + 50}))
line_chart_1 = line(x='x', y='y')

d = cux_df.dashboard([line_chart_1])
line_chart_1.view()

Scatter chart

datashader.scatter(y, x_range=None, y_range=None, add_interaction=True, color_palette=['#440154', '#472777', '#3E4989', '#30678D', '#25828E', '#1E9C89', '#35B778', '#6BCD59', '#B2DD2C', '#FDE724'], aggregate_col=None, aggregate_fn='count', point_size=1, point_shape='circle', pixel_shade_type='eq_hist', pixel_density=0.5, pixel_spread='dynspread', tile_provider=None, width=800, height=400, title='', timeout=100, legend=True, legend_position='center', **library_specific_params)
Parameters
x: str

x-axis column name from the gpu dataframe

y: str, default None

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[y].min(), gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
color_palette: bokeh.palettes or list of hex_color_codes, or list of

color names, default CUXF_DEFAULT_COLOR_PALETTE(Virisdis10)

aggregate_col: str, default None

column from the gpu dataframe on which the aggregate_fn will be run on, if None, aggregate_fn is run on y-column

aggregate_fn: {‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
point_size: int, default 1

Point size in the scatter plot.

point_shape: str, default ‘circle’

Available options: circle, square, rect_vertical, rect_horizontal.

pixel_shade_type: str, default ‘eq_hist’

The “how” parameter in datashader.transfer_functions.shade() function. Available options: eq_hist, linear, log, cbrt

pixel_density: float, default 0.5

A tuning parameter in [0, 1], with higher values giving more dense scatter plot.

pixel_spread: str, default ‘dynspread’

dynspread: Spread pixels in an image dynamically based on the image density. spread: Spread pixels in an image.

tile_provider: str, default None

Underlying map type.See https://docs.bokeh.org/en/latest/docs/reference/tile_providers.htm

width: int, default 800
height: int, default 400
title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

legend: bool, default True

Adds Bokeh.models.LinearColorMapper based legend if True, Note: legend currently only works with pixel_shade_type=’linear’/’log’

legend_position: str, default ‘center’

position of legend on the chart. Valid places are: ‘left’, ‘right’, ‘above’, ‘below’, ‘center’

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader scatter plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import DataFrame
from cuxfilter.charts import scatter
import cudf
import random

cux_df = DataFrame.from_dataframe(cudf.DataFrame({'x': [float(random.randrange(-8239000,-8229000)) for i in range(10000)], 'y':[float(random.randrange(4960000, 4980000)) for i in range(10000)]}))
# setting pixel_shade_type='linear' to display legend (currently supports only log/linear)
scatter_chart = scatter(x='x',y='y', pixel_shade_type="linear")

d = cux_df.dashboard([scatter_chart])
scatter_chart.view()

Stacked_Lines chart

datashader.stacked_lines(y, data_points=100, add_interaction=True, colors=[], step_size=None, step_size_type=<class 'int'>, width=800, height=400, title='', timeout=100, legend=True, legend_position='center', **library_specific_params)

stacked lines chart

Parameters
x: str

x-axis column name from the gpu dataframe

y: list

y-axis column names from the gpu dataframe for the stacked lines

add_interaction: {True, False}, default True
colors: list, default [#8735fb, #8735fb, ….]
step_size: int, default None

for the range_slider below the chart

step_size_type: type, default int

for the range_slider below the chart

width: int, default 800
height: int, default 400
title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

legend: bool, default True

Adds Bokeh.models.LinearColorMapper based legend if True, Note: legend currently only works with pixel_shade_type=’linear’/’log’

legend_position: str, default ‘center’

position of legend on the chart. Valid places are: ‘left’, ‘right’, ‘above’, ‘below’, ‘center’

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader stacked_lines plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter.sampledata import signals_data
from cuxfilter import DataFrame
from cuxfilter.charts import stacked_lines

cux_df = DataFrame.from_dataframe(signals_data)

stacked_lines_chart = stacked_lines(x='Time', y=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'],
                                                    colors = ["red", "grey", "black", "purple", "pink",
                                                            "yellow", "brown", "green", "orange", "blue"]
                                                    )

d = cux_df.dashboard([stacked_lines_chart])

stacked_lines_chart.view()

Heat Map chart

datashader.heatmap(y, x_range=None, y_range=None, add_interaction=True, color_palette=['#440154', '#472777', '#3E4989', '#30678D', '#25828E', '#1E9C89', '#35B778', '#6BCD59', '#B2DD2C', '#FDE724'], aggregate_col=None, aggregate_fn='mean', point_size=10, point_shape='rect_vertical', width=800, height=400, title='', timeout=100, legend=True, legend_position='center', **library_specific_params)

Heatmap using default datashader.scatter plot with slight modifications. Added for better defaults. In theory, scatter directly can be used to generate the same.

Parameters
x: str

x-axis column name from the gpu dataframe

y: str, default None

y-axis column name from the gpu dataframe

x_range: tuple, default(gpu_dataframe[x].min(), gpu_dataframe[x].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(gpu_dataframe[y].min(), gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
color_palette: bokeh.palettes or list of hex_color_codes, or

list of color names,default CUXF_DEFAULT_COLOR_PALETTE(viridis10)

aggregate_col: str, default None

column from the gpu dataframe on which the aggregate_fn will be run on, if None, aggregate_fn is run on y-column

aggregate_fn: {‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
point_size: int, default 1

Point size in the scatter plot.

point_shape: str, default ‘rect_vertical’

Available options: circle, square, rect_vertical, rect_horizontal.

pixel_density: float, default 0.5

A tuning parameter in [0, 1], with higher values giving more dense scatter plot.

pixel_spread: str, default ‘dynspread’

dynspread: Spread pixels in an image dynamically based on the image density. spread: Spread pixels in an image.

width: int, default 800
height: int, default 400
title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

legend: bool, default True

Adds Bokeh.models.LinearColorMapper based legend if True,

legend_position: str, default ‘center’

position of legend on the chart. Valid places are: ‘left’, ‘right’, ‘above’, ‘below’, ‘center’

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader heatmap (scatter object).
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

from cuxfilter import layouts, themes, DataFrame
from cuxfilter.charts import heatmap
from cuxfilter.sampledata import unemployment_data

cux_df = DataFrame.from_dataframe(unemployment_data)

# this is the colormap from the original NYTimes plot
colors = ["#75968f", "#a5bab7", "#c9d9d3", "#e2e2e2", "#dfccce", "#ddb7b1", "#cc7878", "#933b41", "#550b1d"]

chart1 = heatmap(x='Year', y='Month', aggregate_col='rate',
                            color_palette=colors, point_size=20)

d = cux_df.dashboard([chart1], layout=layouts.single_feature, theme=themes.dark)
chart1.view()

Graph chart

datashader.graph(node_y='y', node_id='vertex', edge_source='source', edge_target='target', x_range=None, y_range=None, add_interaction=True, node_aggregate_col=None, edge_aggregate_col=None, node_aggregate_fn='count', edge_aggregate_fn='count', node_color_palette=['#440154', '#472777', '#3E4989', '#30678D', '#25828E', '#1E9C89', '#35B778', '#6BCD59', '#B2DD2C', '#FDE724'], edge_color_palette=['#000000'], node_point_size=8, node_point_shape='circle', node_pixel_shade_type='eq_hist', node_pixel_density=0.8, node_pixel_spread='dynspread', edge_render_type='direct', edge_transparency=0, curve_params={'curve_total_steps': 100, 'strokeWidth': 1}, tile_provider=None, width=800, height=400, title='', timeout=100, legend=True, legend_position='center', **library_specific_params)
Parameters
node_x: str, default “x”

x-coordinate column name for the nodes cuDF dataframe

node_y: str, default “y”

y-coordinate column name for the nodes cuDF dataframe

node_id: str, default “vertex”

node_id/label column name for the nodes cuDF dataframe

edge_source: str, default “source”

edge_source column name for the edges cuDF dataframe

edge_target=”target”,

edge_target column name for the edges cuDF dataframe

x_range: tuple, default(nodes_gpu_dataframe[x].min(),

nodes_gpu_dataframe[x].max()) (min, max) x-dimensions of the geo-scatter plot to be displayed

y_range: tuple, default(nodes_gpu_dataframe[y].min(),
nodes_gpu_dataframe[y].max())

(min, max) x-dimensions of the geo-scatter plot to be displayed

add_interaction: {True, False}, default True
node_aggregate_col=str, default None,

column from the nodes gpu dataframe on which the mode_aggregate_fn will be run on

edge_aggregate_col=str, default None,

column from the edges gpu dataframe on which the mode_aggregate_fn will be run on

node_aggregate_fn={‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
edge_aggregate_fn={‘count’, ‘mean’, ‘max’, ‘min’}, default ‘count’
node_color_palette=bokeh.palettes or list of hex_color_codes, or list of

color names, default CUXF_DEFAULT_COLOR_PALETTE(viridis10)

edge_color_palette=bokeh.palettes or list of hex_color_codes, or list of

color names, default [“#000000”]

node_point_size: int, default 8

Point size in the scatter plot.

node_point_shape: str, default ‘circle’

Available options: circle, square, rect_vertical, rect_horizontal.

node_pixel_shade_type: str, default ‘eq_hist’

The “how” parameter in datashader.transfer_functions.shade() function. Available options: eq_hist, linear, log, cbrt

node_pixel_density: float, default 0.8

A tuning parameter in [0, 1], with higher values giving more dense scatter plot.

node_pixel_spread: str, default ‘dynspread’

dynspread: Spread pixels in an image dynamically based on the image density. spread: Spread pixels in an image.

edge_render_type: str, default ‘direct’

type of edge render. Available options are ‘direct’/’curved’ *Note: Curved edge rendering is an experimental feature and may throw out of memory errors

edge_transparency: float, default 0

value in range [0,1] to specify transparency level of edges, with 1 being completely transparent

curve_params: dict, default dict(strokeWidth=1, curve_total_steps=100)

control curvature and max_bundle_size if edge_render_type=’curved’

tile_provider: str, default None

Underlying map type.See https://docs.bokeh.org/en/latest/docs/reference/tile_providers.html

width: int, default 800
height: int, default 400
title: str,

chart title

timeout: int (milliseconds), default 100

Determines the timeout after which the callback will process new events without the previous one having reported completion. Increase for very long running callbacks and if zooming feels laggy.

legend: bool, default True

Adds Bokeh.models.LinearColorMapper based legend if True, Note: legend currently only works with pixel_shade_type=’linear’/’log’

legend_position: str, default ‘center’

position of legend on the chart. Valid places are: ‘left’, ‘right’, ‘above’, ‘below’, ‘center’

**library_specific_params:

additional library specific keyword arguments to be passed to the function

Returns
A cudashader graph plot.
Type cuxfilter.charts.datashader.custom_extensions.InteractiveImage

Example

import cuxfilter
import cudf

edges = cudf.DataFrame({
    'source': [0, 0, 0, 0, 1, 1, 1, 0, 1, 2, 1, 1, 2, 0, 0],
    'target': [1, 2, 3, 1, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3]
})

nodes = cudf.DataFrame({
    'vertex': [0, 1, 2, 3],
    'x': [-3.3125157356262207,-1.8728941679000854, 0.9095478653907776, 1.9572150707244873],
    'y': [-1.6965408325195312, 2.470950126647949,-2.969928503036499,0.998791515827179]
})

cux_df = cuxfilter.DataFrame.load_graph((nodes, edges))

chart0 = cuxfilter.charts.datashader.graph(node_pixel_shade_type='linear')

d = cux_df.dashboard([chart0], layout=cuxfilter.layouts.double_feature)
chart0.view()